<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Prof.Master" Inherits="System.Web.Mvc.ViewPage" %>

<script runat="server">

    protected void LinkButton3_Click(object sender, EventArgs e)
    {
        SqlDataSource1.InsertParameters[0].DefaultValue = (GridView1.FooterRow.FindControl("dl2") as DropDownList).Text;
        SqlDataSource1.InsertParameters[1].DefaultValue = (GridView1.FooterRow.FindControl("TextBox1") as TextBox).Text;

        SqlDataSource1.InsertParameters[2].DefaultValue = "1";

        SqlDataSource1.Insert();
        
    }
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	ManageStandardLO
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>StandardLO</h2>
    <p>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            CellPadding="4" DataKeyNames="ID" DataSourceID="SqlDataSource1" 
            ForeColor="#333333" GridLines="None" ShowFooter="True">
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <Columns>
                <asp:TemplateField HeaderText="ID" InsertVisible="False" SortExpression="ID">
                    <EditItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("ID") %>'></asp:Label>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label3" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="WorldStdID" SortExpression="WorldStdID">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList1" runat="server" 
                            DataSourceID="dlst" DataTextField="Name" DataValueField="ID" 
                            SelectedValue='<%# Bind("WorldStdID") %>'>
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="dlst" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:CDIO1ConnectionString1 %>" 
                            SelectCommand="SELECT [Name], [ID] FROM [WorldStandard]">
                        </asp:SqlDataSource>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("WorldStdID") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Description" SortExpression="Description">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#999999" />
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:CDIO1ConnectionString1 %>" 
            DeleteCommand="UPDATE [WorldStdLOs] SET[Status] = 0 WHERE [ID] = @ID" 
            InsertCommand="INSERT INTO [WorldStdLOs] ([WorldStdID], [Description], [Status]) VALUES (@WorldStdID, @Description, @Status)" 
            SelectCommand="SELECT * FROM [WorldStdLOs] WHERE (([Status] = @Status) AND ([WorldStdID] = @WorldStdID))" 
            UpdateCommand="UPDATE [WorldStdLOs] SET [WorldStdID] = @WorldStdID, [Description] = @Description WHERE [ID] = @ID">
            <SelectParameters>
                <asp:Parameter DefaultValue="1" Name="Status" Type="Int32" />
                <asp:QueryStringParameter Name="WorldStdID" QueryStringField="id" 
                    Type="Int32" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="WorldStdID" Type="Int32" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="ID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="WorldStdID" Type="Int32" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="Status" Type="Int32" />
            </InsertParameters>
        </asp:SqlDataSource>
    </p>

</asp:Content>
